{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/components/ContactControl/index.tsx\",\n  _s = $RefreshSig$();\nimport React from 'react';\nimport { observer } from \"mobx-react-lite\";\nimport { Context } from \"../../index\";\nimport { findContactOrReturnNull } from \"../../utils/Contact\";\nimport './ContactControl.scss';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-dev-runtime\";\nconst ContactControl = props => {\n  _s();\n  const {\n    store\n  } = React.useContext(Context);\n  const [findContactWithIndex, setFindContactWithIndex] = React.useState();\n  React.useEffect(() => {\n    if (!props.selfProfile && store.getProfile().id !== props.profile.id) {\n      setFindContactWithIndex({\n        ...findContactWithIndex,\n        ...findContactOrReturnNull(props.profile, store.getProfile(), store.getContacts())\n      });\n    }\n  }, [store.getContacts(), props.profile]);\n  if (!props.selfProfile && store.getProfile().id !== props.profile.id) {\n    if ((findContactWithIndex === null || findContactWithIndex === void 0 ? void 0 : findContactWithIndex.contact) === null) {\n      return /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"contact__control\",\n        children: /*#__PURE__*/_jsxDEV(\"button\", {\n          children: \"\\u0414\\u043E\\u0431\\u0430\\u0432\\u0438\\u0442\\u044C \\u0432 \\u043A\\u043E\\u043D\\u0442\\u0430\\u043A\\u0442\\u044B\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 28,\n          columnNumber: 21\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 27,\n        columnNumber: 17\n      }, this);\n    } else if (findContactWithIndex !== null && findContactWithIndex !== void 0 && findContactWithIndex.contact.status) {\n      return /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"contact__control\",\n        children: /*#__PURE__*/_jsxDEV(\"button\", {\n          children: \"\\u0423\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u043A\\u043E\\u043D\\u0442\\u0430\\u043A\\u0442\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 34,\n          columnNumber: 21\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 33,\n        columnNumber: 17\n      }, this);\n    } else {\n      return /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"contact__control\",\n        children: [(findContactWithIndex === null || findContactWithIndex === void 0 ? void 0 : findContactWithIndex.contact.fromUser.id) === props.profile.id && /*#__PURE__*/_jsxDEV(\"span\", {\n          children: \"\\u0417\\u0430\\u044F\\u0432\\u043A\\u0430 \\u043E\\u0442\\u043F\\u0440\\u0430\\u0432\\u043B\\u0435\\u043D\\u0430\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 41,\n          columnNumber: 25\n        }, this), (findContactWithIndex === null || findContactWithIndex === void 0 ? void 0 : findContactWithIndex.contact.toUser.id) === props.profile.id && /*#__PURE__*/_jsxDEV(\"button\", {\n          children: \"\\u041F\\u0440\\u0438\\u043D\\u044F\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 44,\n          columnNumber: 25\n        }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n          children: \"\\u0423\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 46,\n          columnNumber: 21\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 39,\n        columnNumber: 17\n      }, this);\n    }\n  } else {\n    return /*#__PURE__*/_jsxDEV(_Fragment, {}, void 0, false);\n  }\n};\n_s(ContactControl, \"RiXfrcF99K19X8ie+JdPJy3I23g=\");\n_c = ContactControl;\nexport default _c2 = observer(ContactControl);\nvar _c, _c2;\n$RefreshReg$(_c, \"ContactControl\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","observer","Context","findContactOrReturnNull","ContactControl","props","store","useContext","findContactWithIndex","setFindContactWithIndex","useState","useEffect","selfProfile","getProfile","id","profile","getContacts","contact","status","fromUser","toUser"],"sources":["/data/messenger.client/src/components/ContactControl/index.tsx"],"sourcesContent":["import React from 'react';\nimport {observer} from \"mobx-react-lite\";\nimport {Context} from \"../../index\";\nimport {findContactOrReturnNull} from \"../../utils/Contact\";\nimport {UserProfileProps} from \"../../models/props/UserProfileProps\";\nimport {ContactWithIndex} from \"../../models/props/ContactWithIndex\";\nimport './ContactControl.scss';\n\nconst ContactControl: React.FC<UserProfileProps> = (props) => {\n    const {store} = React.useContext(Context);\n    const [findContactWithIndex, setFindContactWithIndex] = React.useState<ContactWithIndex>();\n\n    React.useEffect(() => {\n        if (!props.selfProfile && store.getProfile().id !== props.profile.id) {\n            setFindContactWithIndex({\n                ...findContactWithIndex,\n                ...findContactOrReturnNull(props.profile, store.getProfile(), store.getContacts())\n            });\n        }\n    }, [store.getContacts(), props.profile]);\n\n    if (!props.selfProfile &&\n        store.getProfile().id !== props.profile.id\n    ) {\n        if (findContactWithIndex?.contact === null) {\n            return (\n                <div className=\"contact__control\">\n                    <button>Добавить в контакты</button>\n                </div>\n            );\n        } else if (findContactWithIndex?.contact.status) {\n            return (\n                <div className=\"contact__control\">\n                    <button>Удалить контакт</button>\n                </div>\n            );\n        } else {\n            return (\n                <div className=\"contact__control\">\n                    {findContactWithIndex?.contact.fromUser.id === props.profile.id &&\n                        <span>Заявка отправлена</span>\n                    }\n                    {findContactWithIndex?.contact.toUser.id === props.profile.id &&\n                        <button>Принять заявку</button>\n                    }\n                    <button>Удалить заявку</button>\n                </div>\n            );\n        }\n    } else {\n        return (<></>);\n    }\n}\n\nexport default observer(ContactControl);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,OAAO,QAAO,aAAa;AACnC,SAAQC,uBAAuB,QAAO,qBAAqB;AAG3D,OAAO,uBAAuB;AAAC;AAAA;AAE/B,MAAMC,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